package com.yunzhou.utils;

import java.util.Random;
import java.util.UUID;

public class MyStringUtil {
    // 判断字符串是否为空
    public static Boolean isEmpty(String str){
        if (str == null || "".equals(str.trim()) || "null".equals(str)) {
            return true;
        } else {
            return false;
        }
    }

    // 生成随机字符串
    public static final String getRandomString(Integer count){
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < count; i++){
            int number = random.nextInt(62);
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }

    // 生成32位的id
    public static final String getUUID(){
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        return uuid;
    }
}
